const singer = [
    { name: '周杰伦', num: 20 },
    { name: '许嵩', num: 25 },
    { name: '林俊杰', num: 19 },
    { name: '蔡徐坤', num: 10 },
    { name: '鹿晗', num: 0 },
]

Array.prototype.my_splice = function (start, length, ...args) {
    if (length === 0) return
    //     const result = [], targetArr = [];
    //     for (let i = start; i < start + length; i++) {
    //     }
    // }
    // const arr = singer.splice(0, 3, 'hello', 'world', 'jitao')
    // console.log(singer);
    const result = [], targetArr = [], tempArr = [...this]
    for (let i = 0; i < this.length; i++) {
        if (i === start) {
            for (let j = start; j < start + length; j++) {
                result.push(this[i]);
                i = j;
            }
            targetArr.push(...args);
        } else {
            targetArr.push(this[i]);
        }
    }
    this = targetArr;
    return result;
}
const arr = singer.splice(0, 3, 'hello', 'world', 'jitao')
console.log(singer);
